package GC_requestUsingMT;


import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import FamilyTherapy.GCWindow;
import FamilyTherapy.MagicToolCard;
import FamilyTherapy.Player;

public class testGCWindow_requestUsimgMT_2 {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testRequestUsingMT_2() {
		GCWindow gwindow = new GCWindow();
		Player[] p ={new Player("a",1),new Player("b",2)};
		p[0].addHoldingCard(2);
		MagicToolCard m=new MagicToolCard();
		int result;
		
		final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
		System.setOut(new PrintStream(outContent));
		
		
		String expected = "Does a want to use Magic Tool card? Enter \'y\'es or \'n\'o : \n" +
		"You're currently holding: \n"+
		"[2]\n"+
		"\nWhich one do you want to use? Please enter the card number: \n" +
		"\n[C]onfirm or [D]ismiss\n" ;

	
		//for input
		String data = "y 2 c"; 	//data to be input 
		InputStream stdin = System.in; 
		try {   
			System.setIn(new ByteArrayInputStream(data.getBytes()));	//put data to input stream
			result=gwindow.requestUsingMT(0,p);	//for getting data from input stream
		} 
		finally {  
			System.setIn(stdin); 	//reset input stream as System.in
		} 
		
		//for testing
		assertEquals(expected,outContent.toString());
		assertEquals(2,result);
		
	}

}
